package com.weibo.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.List;

import weibo4j.Status;
import weibo4j.WeiboException;

import com.weibo.db.DataBaseConnection;
import com.weibo.entity.JianceGuanjianzi;
import com.weibo.entity.KOL;

public class JianceGuanjianziService  extends  DataBaseConnection{
	
	public void delete(int id){
		try {
			String sql = "delete from t_jiance_guanjianzi where id="+id ;
				super.delete(sql);
			
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				super.closeAll();
			}
	}
	
	public void add(String guanjianzi){
		
		try {
			String sql = "insert into t_jiance_guanjianzi(guanjianzi) " +
					"values ('"+guanjianzi+"')";
				super.save(sql);
			
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				super.closeAll();
			}
	}
	
	
	public List<Object> findAll(){
		
		String sql = "select * from t_jiance_guanjianzi";
		ResultSet rs=null;
		try {
			rs = super.getResultSet(sql, null);
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		List<Object> list = new LinkedList<Object>();
		JianceGuanjianzi zi = null;
		try {
			while(rs.next()){
				zi = new JianceGuanjianzi();
				zi.setId(rs.getInt("id"));
				zi.setGuanjianzi(rs.getString("guanjianzi"));
				list.add(zi);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally{
			super.closeAll();
		}
		return list;
	}
	
public List<JianceGuanjianzi> list(){
		
		String sql = "select * from t_jiance_guanjianzi";
		ResultSet rs=null;
		try {
			rs = super.getResultSet(sql, null);
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		List<JianceGuanjianzi> list = new LinkedList<JianceGuanjianzi>();
		JianceGuanjianzi zi = null;
		try {
			while(rs.next()){
				zi = new JianceGuanjianzi();
				zi.setId(rs.getInt("id"));
				zi.setGuanjianzi(rs.getString("guanjianzi"));
				list.add(zi);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally{
			super.closeAll();
		}
		return list;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
